/**
 * Copyright (c) 2010 Basil Shikin, BugStat Project
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.bugstat.exporters;

import java.util.Date;

import org.bugstat.common.TimeInterval;
import org.bugstat.common.utils.ProgressListener;
import org.bugstat.exporters.systems.BugExporterBase;
import org.bugstat.exporters.systems.bugzilla.BugzillaExporter;


/**
 * This interface defines a class that is able to export all information about bugs from a bug tracking
 * system into BugStat temporal storage.
 * 
 * <p>
 * You can either implement <code>BugExporter</code> interface directly or use {@link BugExporterBase} base
 * class that provides some common functionality for exporters. Bug exporter must be annotated with {@link CanExportBugs}
 * for it to be picked up.
 * 
 * <p>
 * Please note Bugzilla implementation ({@link BugzillaExporter}): it could be a good example of a simple 
 * exporter structure. 
 *
 * @author Basil Shikin
 *
 */
public interface BugExporer
{
    /**
     * Export bugs from supported bug tracker into BugStat temporal storage. 
     * <p>
     * This method requires time step parameter. This parameter specifies how often
     * bug tracker should be sampled. For example, if time step is set to 'week',
     * exporter should create one temporal file per week, thus creating about 52
     * files for whole year. <br>
     * Note that each temporal file will contain state of all bugs as of given date.
     * For more information see {@link BugTemporalInfoWriter}.
     * 
     * @param interval  Time interval to export bugs in. Must not be null.
     * @param listener  Lister to notify of current export progress. May be null.
     * 
     * @throws ExportException In case unable to export bugs.
     */
    public void exportBugs(TimeInterval interval, final ProgressListener listener) throws ExportException;

    /**
     * Set managers to use
     * 
     * @param connectionManager Manager of database connections. Must not be null.
     * @param storageManager    Manager that saves files to disk. Must not be null.
     */
    public void setManagers(ConnectionManager connectionManager, StorageManager storageManager);
    
    /**
     * Get user-friendly (and possibly localized) name of the bug tracking system this exporter
     * can export bugs from
     * 
     * @return User-friendly bug tracker name (for example, "Bugzilla" or "Trac")
     */
    public String getBugTrackerName();
    
    /**
     * Retrieve a date of the first bug available in the system
     * 
     * @return Date of the first bug
     * 
     * @throws ExportException In case unable to retrieve date of the first bug
     */
    public Date retrieveFirstBugDate() throws ExportException;

}